import urllib.request
import requests
import ssl
import json
from k8sMp.settings import logger


context = ssl._create_unverified_context()  #取消ssl认证

def get_api_url(api_url):
    try:
        #res = requests.get(api_url,timeout=10,verify=False).text
        res = urllib.request.urlopen(api_url,context=context,timeout=10).read().decode('gbk')
        result = json.loads(res)
        return result
    except Exception as e:
        result = {"error": e}
        logger.error(result)
        return result

# api_url = 'https://121.52.238.150:6443/api/v1/pods'
# aa = get_api_url(api_url)
# print(aa)
